<?php
if (!defined('IN_XLP')) {
    exit('Access Denied');
}
$Document = array(
    'pageid' => 'advs-add', //页面标示
    'pagename' => '添加广告', //当前页面名称
    'mycss' => array(), //加载的css样式表
    'myjs' => array(), //加载的js脚本
	'footerjs'=>array('content/fuelux/fuelux','content/combodate/moment.min','content/combodate/combodate','content/calendar'),
    'head' => true, //加载头部文件
);
include getTpl('header', 'public');
?>
<!--顶部导航 开始-->
<?php include getTpl('top', 'public');?>
<!--顶部导航 结束-->
<!--左侧菜单 开始-->
<?php include getTpl('nav', 'public');?>
<!--左侧菜单 结束-->
<!--主体 开始-->
<section id="content">
  <section class="main padder">
    <div class="clearfix">
      <h4><i class="fa fa-edit"></i><?php echo trim($Document['pagename'],'_');?></h4>
    </div>
    <div class="row">
      <div class="col-sm-12">
        <section class="panel">
          <div class="panel-body">
            <form class="form-horizontal" method="post" id="form1">
              <div class="form-group">
                <label class="col-sm-1 control-label">所属游戏</label>
                <div class="col-sm-2">
                    <select id="game_id" name="game_id" class="form-control">
                        <option value="-1">选择游戏</option>
                        <?php foreach ($games as $k => $v): ?>
                        <option value="<?php echo $v['id'] ?>"><?php echo $v['name']?></option>
                        <?php endforeach ?>
                    </select>
                </div>
              </div>
              <div class="form-group">
                  <label class="col-sm-1 control-label">广告位置</label>
                  <div class="col-sm-3">
                      <select id="position_id" class="form-control" name="position_id">
                      <?php
                      if ($advsPath){
                          foreach($advsPath as $k=>$v){
                      ?>
                          <option value="<?php echo $k;?>"><?php echo $v['name'];?>[<?php echo $v['size']?>]</option>
                      <?php
                          }
                      }
                      ?>
                      </select>
                  </div>
                </div>
              <div class="form-group">
                <label class="col-sm-1 control-label">广告名称</label>
                <div class="col-sm-3">
                  <input type="text" name="title" id="title" placeholder="" class="form-control" value="" />
                  <span class="help-block">标题不能长于64个字符</span></div>
              </div>
              <div class="form-group">
                <label class="col-sm-1 control-label">广告链接</label>
                <div class="col-sm-3">
                  <input type="text" name="link_url" id="link_url" placeholder="" class="form-control" value="" />
                  <span class="help-block">点击广告时跳转的目标页面</span></div>
              </div>
              <div class="form-group">
                <label class="col-sm-1 control-label">图片地址</label>
                <div class="col-sm-3">
                  <input type="text" name="img_url" id="img_url" placeholder="" class="form-control" value="" />
                  <span class="help-block">请注意广告标准尺寸</span></div>
                <div class="col-sm-3">
                  <iframe width="280" height="24" src="<?php echo U('upload/index',array('id'=>'img_url')); ?>" scrolling="no" frameborder="0"></iframe>
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-1 control-label">开始时间</label>
                <div class="col-sm-3">
                  <input type="text" name="stime" id="stime" placeholder="" class="form-control" value="" readonly  style="width:222px"/>
                  <span class="help-block"></span></div>
              </div>
              <div class="form-group">
                <label class="col-sm-1 control-label">结束时间</label>
                <div class="col-sm-3">
                  <input type="text" name="etime" id="etime" placeholder="" class="form-control" value="" readonly  style="width:222px"/>
                  <span class="help-block"></span></div>
              </div>
              <div class="form-group">
                <label class="col-sm-1 control-label">备注信息</label>
                <div class="col-sm-6">
                  <textarea class="form-control" id="content" name="content"  style="height:80px"></textarea>
                  <span class="help-block"></span></div>
              </div>
              <!-- <div class="form-group">
                <label class="col-sm-1 control-label">排序</label>
                <div class="col-sm-3">
                  <input type="text" name="px" id="px" placeholder="" class="form-control" value="0"  style="width:80px"/>
                  <span class="help-block">0-999之间，数字越大越靠前</span></div>
              </div> -->
              <div class="form-group">
                <label class="col-sm-1 control-label">状态</label>
                <div class="col-sm-5">
                  <div class="row">
                  <?php
                    foreach($status as $key=>$val){
			            ?>
                    <div class="col-xs-2 radio m-l-large">
                      <label class="radio-custom">
                        <input type="radio" name="status"  value="<?php echo $key;?>" <?php if ($key){echo 'checked="checked"';}?>/>
                        <i class="fa fa-circle-o"></i><?php echo $val;?></label>
                    </div>
          				<?php
          				  }
          				?>
                  </div>
                  <span class="help-block"></span></div>
              </div>
              <div class="form-group">
                <div class="col-sm-9 col-lg-offset-1">
                  <div class="col-sm-1">
                    <button type="submit" id="sub-ok" data-loading-text="正在提交..." class="btn btn-primary">保存</button>
                  </div>
                  <div class="col-md-offset-2">
                    <button type="button" class="btn btn-white">取消</button>
                  </div>
                </div>
              </div>
            </form>
          </div>
        </section>
      </div>
    </div>
  </section>
</section>
<!--主体 结束--> 
<link rel="stylesheet" media="screen" href="<?php echo PUBLIC_PATH; ?>jquery-ui/css/smoothness/jquery-ui-1.10.0.custom.min.css"/>
<script type="text/javascript" src="<?php echo PUBLIC_PATH; ?>jquery-ui/js/jquery-ui-1.10.0.custom.min.js"></script>
<script type="text/javascript" src="<?php echo PUBLIC_PATH; ?>jquery-ui/js/jquery-ui-timepicker-addon.js"></script>
<script>
$(function(){
	$('#stime').datetimepicker();
  $('#etime').datetimepicker();
	$('#form1').submit(function(){
		var title=$.trim($("#title").val());
		var isOk=true;
		if (!title){
			Msg.error('名称不能为空');
			resetSubmit("#sub-ok",'保存');
			return false;
		}
		Msg.loading();
		  $.post('<?php echo U('advs/post');?>',$(this).serialize(),function(result){
			  Msg.hide();
			  resetSubmit("#sub-ok",'保存');
			  if (result.status==1){
				Msg.ok('添加成功',function(){
					document.location='<?php echo U('advs/index');?>';	
				},1000);  
			}else{
				Msg.error(result.info);
			}
		  },'json');
		  return false;
	});
})
</script>
<?php
include getTpl('footer', 'public');
?>